package com.ruoyi.zikao.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.gaokao.domain.GkCandidateRegistration;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.zikao.domain.ZikaoCandidateRegistration;
import com.ruoyi.zikao.service.IZikaoCandidateRegistrationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 自考考生报名Controller
 * 
 * @author ruoyi
 * @date 2025-07-10
 */
@Api(tags = "自考-考生报名管理")
@RestController
@RequestMapping("/zikao/registration")
public class ZikaoCandidateRegistrationController extends BaseController
{
    @Autowired
    private IZikaoCandidateRegistrationService zikaoCandidateRegistrationService;

    @Log(title = "考生报名信息", businessType = BusinessType.OTHER)
    @PostMapping("/upsert")
        @ApiOperation("自考考生报名信息管理 - 插入或更新数据")
    public AjaxResult upsert(@RequestBody ZikaoCandidateRegistration zikaoCandidateRegistration){
        return toAjax(zikaoCandidateRegistrationService.upsertzikaoCandidateRegistration(zikaoCandidateRegistration));
    }
    /**
     * 查询自考考生报名列表
     */
    //@PreAuthorize("@ss.hasPermi('zikao:registration:list')")
    @GetMapping("/list")
        @ApiOperation("自考考生报名信息管理 - 分页查询列表")
    public TableDataInfo list(ZikaoCandidateRegistration zikaoCandidateRegistration)
    {
        startPage();
        List<ZikaoCandidateRegistration> list = zikaoCandidateRegistrationService.selectZikaoCandidateRegistrationList(zikaoCandidateRegistration);
        return getDataTable(list);
    }

    /**
     * 导出自考考生报名列表
     */
    @PreAuthorize("@ss.hasPermi('zikao:registration:export')")
    @Log(title = "自考考生报名", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
        @ApiOperation("自考考生报名信息管理 - 导出数据")
    public void export(HttpServletResponse response, ZikaoCandidateRegistration zikaoCandidateRegistration)
    {
        List<ZikaoCandidateRegistration> list = zikaoCandidateRegistrationService.selectZikaoCandidateRegistrationList(zikaoCandidateRegistration);
        ExcelUtil<ZikaoCandidateRegistration> util = new ExcelUtil<ZikaoCandidateRegistration>(ZikaoCandidateRegistration.class);
        util.exportExcel(response, list, "自考考生报名数据");
    }

    /**
     * 获取自考考生报名详细信息
     */
    //@PreAuthorize("@ss.hasPermi('zikao:registration:query')")
    @GetMapping(value = "/{idNumber}")
        @ApiOperation("自考考生报名信息管理 - 根据ID获取详细信息")
    public AjaxResult getInfo(@PathVariable("idNumber") String idNumber)
    {
        return success(zikaoCandidateRegistrationService.selectZikaoCandidateRegistrationByIdNumber(idNumber));
    }

    /**
     * 新增自考考生报名
     */
    //@PreAuthorize("@ss.hasPermi('zikao:registration:add')")
    @Log(title = "自考考生报名", businessType = BusinessType.INSERT)
    @PostMapping
        @ApiOperation("自考考生报名信息管理 - 新增数据")
    public AjaxResult add(@RequestBody ZikaoCandidateRegistration zikaoCandidateRegistration)
    {
        return toAjax(zikaoCandidateRegistrationService.insertZikaoCandidateRegistration(zikaoCandidateRegistration));
    }

    /**
     * 修改自考考生报名
     */
    //@PreAuthorize("@ss.hasPermi('zikao:registration:edit')")
    @Log(title = "自考考生报名", businessType = BusinessType.UPDATE)
    @PutMapping
        @ApiOperation("自考考生报名信息管理 - 修改数据")
    public AjaxResult edit(@RequestBody ZikaoCandidateRegistration zikaoCandidateRegistration)
    {
        return toAjax(zikaoCandidateRegistrationService.updateZikaoCandidateRegistration(zikaoCandidateRegistration));
    }

    /**
     * 删除自考考生报名
     */
    //@PreAuthorize("@ss.hasPermi('zikao:registration:remove')")
    @Log(title = "自考考生报名", businessType = BusinessType.DELETE)
	@DeleteMapping("/{idNumbers}")
        @ApiOperation("自考考生报名信息管理 - 删除数据")
    public AjaxResult remove(@PathVariable String[] idNumbers)
    {
        return toAjax(zikaoCandidateRegistrationService.deleteZikaoCandidateRegistrationByIdNumbers(idNumbers));
    }
}
